<%--
  Created by IntelliJ IDEA.
  User: 14394
  Date: 2018/4/27
  Time: 21:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>第六题</title>
</head>
<body>

    <%
        //获取当前回话的sessionId
        String temp =  request.getSession().getId();
        //将当前会话的id 存入session
        request.getSession().setAttribute("sessionId",temp);

        //从session中取出次数
        Integer timeTmp = (Integer) request.getSession().getAttribute("time");

        //将次数分情况进行更新
        int time=0;
        if (timeTmp ==null){
            time =1;
        }else if (timeTmp != null&&timeTmp!=0 && request.getSession().getAttribute("sessionId") != null){
            time = timeTmp;
            time += timeTmp;
        }else {
            time =1;
        }
        //更新操作
        request.getSession().setAttribute("time",time);
        //输出结果
        out.write("sessionId为"+temp +"的用户，访问了："+time+"次");
    %>

</body>
</html>
